package com.lais.record.common.exception;

import com.lais.record.common.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: luowen
 * @Description:
 * @Date: Create in 20:21 2019/11/29
 */
@Slf4j
public class RecordExceptionAdvice {

    @ExceptionHandler(RecordException.class)
    public Result handlerRecordException(RecordException recordException){
        log.error("全局自定义异常---异常信息为：{}",recordException);
        Result<Object> result = new Result<>();
        result.setFlag(false);
        result.setCode(recordException.getCode());
        result.setMessage(recordException.getMessage());
        return result;
    }
    @ExceptionHandler(Exception.class)
    public Result handlerException(Exception ex){
        return Result.fail();
    }
}
